﻿using Hotel_Project.HotelForm;
using Hotel_Project.Tools.MySqlData_Helps;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel_Project.BIZ
{
    public class Guest_History_Jjh
    {
        //删除客户记录
        public void delUrse(Guest_HistoryFrom form)
        {
            int paper = Dao_MySql_Jjh.Execut($"update hotel_main set false_del = 0 where hotel_id = s{Convert.ToInt32(form.VIP_DataGrid.CurrentRow.Cells[0].Value)}");
            if (paper != 0)
            {
                form.label2.Text = "没有该编号!";
            }
            else form.label2.Text = "删除成功!";
        }

        public void push_data(Guest_HistoryFrom form)
        {
            //增加combox
            form.comboBox1.Items.Clear();
            form.VIP_DataGrid.Rows.Clear();
            form.comboBox1.Items.Add("全部");
            DataSet data = Dao_MySql_Jjh.Read_Ececut("select FId from floor");
            foreach (DataRow row in data.Tables[0].Rows)
            {
                form.comboBox1.Items.Add(row[0].ToString());
            }

            //增加GradeView
            DataSet urse = Dao_MySql_Jjh.Read_Ececut("SELECT * FROM hotel_main");
            foreach (DataRow item in urse.Tables[0].Rows)
            {
                if (item[10].ToString() != "1") continue;
                form.VIP_DataGrid.Rows.Add(item[0], item[1], item[2], item[4], item[5], item[6], item[8]);
            }
        }

        public void push_grid(Guest_HistoryFrom form)
        {
            if (form.comboBox1.SelectedItem.ToString() == "") return;
            if (form.comboBox1.SelectedItem.ToString() == "全部")
            {
                DataSet urse = Dao_MySql_Jjh.Read_Ececut("SELECT * FROM hotel_main");
                foreach (DataRow item in urse.Tables[0].Rows)
                {
                    if (item[10].ToString() != "1") continue;
                    form.VIP_DataGrid.Rows.Add(item[0], item[1], item[2], item[4], item[5], item[6], item[8]);
                }
            }
            else
            {
                DataSet urse = Dao_MySql_Jjh.Read_Ececut($"SELECT * FROM hotel_main where hotel_affilationFloor={Convert.ToInt32(form.comboBox1.SelectedItem.ToString())}");
                foreach (DataRow item in urse.Tables[0].Rows)
                {
                    if (item[10].ToString() != "1") continue;
                    form.VIP_DataGrid.Rows.Add(item[0], item[1], item[2], item[4], item[5], item[6], item[8]);
                }
            }
        }
    }
}
